<!--手动录入text-->
<template>
  <a-modal v-model:visible="props.visible" title="参数设置" destroyOnClose  :canFullscreen="false" width="580px" @ok="handleOk" @cancel="handleCancel">
    <AiModelSeniorForm ref="aiModelSeniorFormRef" :type="type"></AiModelSeniorForm>
  </a-modal>
</template>

<script setup>
import {onMounted, ref} from 'vue';
import AiModelSeniorForm from '@/views/super/airag/aimodel/components/AiModelSeniorForm.vue';

    const emits = defineEmits(['ok', 'register']);

    const props = defineProps({
      visible: Boolean,
       data: Object
    });

    let aiModelSeniorFormRef = ref();

    //类型
    const type = ref('');
    //注册modal
    onMounted(async () => {
      type.value = props.data.type;
      if(props.data.type === 'model'){
        if(!props.data.metadata.hasOwnProperty("temperature") ){
          props.data.metadata['temperature'] = 0.7;
        }
      }else{
        if(!props.data.metadata.hasOwnProperty("topNumber") ){
          props.data.metadata['topNumber'] = 4;
        } 
        if(!props.data.metadata.hasOwnProperty("similarity") ){
          props.data.metadata['similarity'] = 0.76;
        }
      }
      setTimeout(()=>{
        aiModelSeniorFormRef.value.setModalParams(props.data.metadata);
      })
    });

    /**
     * 弹窗点击事件
     */
    function handleOk() {
      let emitChange = aiModelSeniorFormRef.value.emitChange();
      emits('ok',emitChange);
      handleCancel();
    }

    /**
     * 弹窗关闭事件
     */
    function handleCancel() {
      emits('update:visible', false); // 通知父组件关闭
    }


</script>

<style scoped lang="less">
.pointer {
  cursor: pointer;
}
.header {
  font-size: 16px;
  font-weight: bold;
  margin-top: 10px;
}
.content {
  margin-top: 20px;
  max-height: 600px;
  overflow-y: auto;
  overflow-x: auto;
}
.title-tag {
  color: #477dee;
}
</style>
